import Vue from 'vue'
import VueRouter from 'vue-router'

const Home = () => import('../views/Home')
const Classification = () => import('../views/Classification')
const Cart = () => import('../views/Cart')
const Profile = () => import('../views/Profile')
const Search = () => import('../views/Search')
const searchlist = () => import('../views/search-list')
const Detail = () => import('../views/Detail')
const Login = () => import('../views/Login')
const LoginCode = () => import('../views/LoginCode')
const Payment = () => import('../views/Payment')
const Address = () => import('../views/Address')
const addAddress = () => import('../views/addaddress')

const HomePage = () => import('@/components/home/children/HomePage')
const BeatsSolo3 = () => import('@/components/home/children/BeatsSolo3')
const BeatsFlex = () => import('@/components/home/children/BeatsFlex')
const PowerBeats = () => import('@/components/home/children/PowerBeats')
const PowerBeatsPro = () => import('@/components/home/children/PowerBeatsPro')
const SoloPro = () => import('@/components/home/children/SoloPro')
const BeatsStudio3 = () => import('@/components/home/children/BeatsStudio3')
const BeatsEP = () => import('@/components/home/children/BeatsEP')
const BeatsPill = () => import('@/components/home/children/BeatsPill')
Vue.use(VueRouter)

const routes = [
  {
    path: '',
    redirect: '/home'
  },{
    path: '/home',
    component: Home,
    children:[
      {
        path: '',
        redirect: 'Homepage'
      }, {
        path: 'HomePage',
        component: HomePage
      }, {
        path: 'BeatsSolo3',
        component: BeatsSolo3
      }, {
        path: 'BeatsFlex',
        component: BeatsFlex
      },  {
        path: 'PowerBeats',
        component: PowerBeats
      }, {
        path: 'PowerBeatsPro',
        component: PowerBeatsPro
      },{
        path: 'BeatsStudio3',
        component: BeatsStudio3
      }, {
        path: 'SoloPro',
        component: SoloPro
      }, {
        path: 'BeatsEP',
        component: BeatsEP
      }, {
        path: 'BeatsPill',
        component: BeatsPill
      }
    ]
  },{
    path: '/classification',
    component: Classification
  },{
    path: '/cart',
    component: Cart
  },{
    path: '/profile',
    component: Profile
  },{
    path: '/search',
    component: Search,
    meta: {
      keepAlive: false
    }
  },{
    path: '/search-list',
    component: searchlist
  },{
    path: '/detail',
    component: Detail
  },{
    path: '/login',
    component: Login
  },{
    path: '/loginCode',
    component: LoginCode
  },{
    path: '/payment',
    component: Payment
  },{
    path: '/address',
    component: Address
  },{
    path: '/addaddress',
    component: addAddress
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to ,from,  next) =>{

  next()
})

export default router
